package com.yanghang.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yanghang.dao.CarDao;
import com.yanghang.entity.Car;
import com.yanghang.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarServiceImpl implements CarService {
    @Autowired
    private CarDao cd;
    @Override
    public PageInfo<Car> selectCarByPage(int tid,int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Car> list = cd.selectAllCarByTypeId(tid);
        return new PageInfo<>(list);
    }

    @Override
    public Car selecCartById(int id) {
      return cd.selectById(id);
    }

    @Override
    public void updateCar(Car car) {
        cd.updateById(car);
    }

    @Override
    public void insertCar(Car car) {
        cd.insert(car);
    }

    @Override
    public void deleteCar(int id) {
        cd.deleteById(id);
    }
}
